package com.project.controller;


import com.project.bean.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@Controller
public class TestController {

    @RequestMapping("test")
    public String test(HttpServletRequest req){
        //绑定共享数据
        req.setAttribute("name","刘勇");
        req.setAttribute("age",15);

        List<UserBean> userList = new ArrayList<>();
        userList.add(new UserBean(1,"赵军","13039448394"));
        userList.add(new UserBean(5,"刘三","18920392838"));
        userList.add(new UserBean(3,"何勇","15940598490"));
        userList.add(new UserBean(8,"朱大","17739403945"));

        req.setAttribute("list",userList);

        //请求转发到指定页面
        return "redirect:/showInfo.html";
    }
}
